package com.mzy.basics.utils.Date;

import lombok.extern.slf4j.Slf4j;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * @author Ives
 * * @date 2021/12/27
 */
@Slf4j
public class DateToLocalDate {

  /**
   * 功能描述：Date转换为LocalDate
   *
   * @param date
   * @return
   */
  public static LocalDate dateToLocalDate(Date date) {

    try {
      Instant instant = date.toInstant();
      LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
      return localDateTime.toLocalDate();
    } catch (Exception e) {
      log.error("======> Date转换为LocalDate失败，错误信息:{}", e);
    }
    return null;
  }



}
